<?php
/**
 * User: papa
 * Date: 18/5/10
 * Time: 11:45
 */

namespace app\admin\model;


class Banner extends BaseModel
{

    //指定条件查询及分页样式
    public static function getAllBanner($num,$data = null)
    {
        if (!empty($data['name']))  $where['name'] = ['like','%'.$data['name'].'%'];
        if(!isset($where))  $where = null;
        $result = self::where($where)->order('create_time', 'asc')
            ->paginate($num, false, [
                'type' => 'page\Page',
            ]);
        return $result;
    }

    //关联banner_item
    public function item()
    {
        return $this->hasMany('BannerItem','banner_id','id');
    }

}